static void op_brk_imp()
{
//log_message("brk at $%04X\n",d6502_pc-1);
//for(;;);
d6502_pc++;
d6502_f |= FLAG_BRK;
push(d6502_pc >> 8);
push(d6502_pc);
push(d6502_f);
d6502_f |= FLAG_IRQDISABLE;
d6502_pc = hu6280_read(0xfffe);
d6502_pc |= hu6280_read(0xffff) << 8;
}

void hu6280_push(u8 d){push(d);}
u8 hu6280_pop(){u8 ret;pop(ret);return(ret);}


#define ZEROPAGE(addr)	hu6280_read((addr) | 0x2000)


static void op_tsb_zpg()
{
	//get address of data, then logically OR the accumulator
	//with the data, then store the result at that address.
	addr = hu6280_read(d6502_pc++) | 0x2000;
	d6502_a |= hu6280_read(addr);
	hu6280_write(addr,d6502_a);

	//set flags
	d6502_f &= 0x3D;
	d6502_f |= value & 0xC0;
	if((d6502_a & value) == 0)
		d6502_f |= FLAG_ZERO;
}

static void op_tsb_abs()
{
	//get address of data, then logically or the accumulator
	//with the data, then store the result at that address.
	addr = hu6280_read(d6502_pc++);
	addr |= hu6280_read(d6502_pc++) << 8;
	value = hu6280_read(addr);
	d6502_a |= value;
	hu6280_write(addr,d6502_a);

	//set flags
	d6502_f &= 0x3D;
	d6502_f |= d6502_a & 0xC0;
	if((d6502_a & value) == 0)
		d6502_f |= FLAG_ZERO;
}

static void op_ora_inx()
{
u16 zpaddr = 0x2000;

zpaddr |= hu6280_read(d6502_pc++);
addr = hu6280_read(zpaddr);
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
zpaddr &= 0x20FF;
addr |= hu6280_read(zpaddr) << 8;
d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ora_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_asl_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
d6502_f &= FLAG_CARRY_MASK;
if(value & 0x80)
	d6502_f |= FLAG_CARRY;
value = value << 1;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_php_imp()
{
////opcycles++;
push(d6502_f | FLAG_BRK);
}
/************************************************************************************************/
static void op_ora_imm()
{
addr = d6502_pc++;

//opcycles++;
d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_asl_acc()
{
//opcycles++;
d6502_f &= FLAG_CARRY_MASK;
if(d6502_a & 0x80)
	d6502_f |= FLAG_CARRY;
d6502_a = d6502_a << 1;
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ora_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_asl_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
d6502_f &= FLAG_CARRY_MASK;
if(value & 0x80)
	d6502_f |= FLAG_CARRY;
value = value << 1;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_bpl_rel()
{
branch((d6502_f & FLAG_NEGATIVE) == 0);
}
/************************************************************************************************/
static void op_ora_iny()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ora_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_asl_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(value & 0x80)
	d6502_f |= FLAG_CARRY;
value = value << 1;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_clc_imp()
{
d6502_f &= FLAG_CARRY_MASK;
}
/************************************************************************************************/
static void op_ora_aby()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ora_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a |= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_asl_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(value & 0x80)
	d6502_f |= FLAG_CARRY;
value = value << 1;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_jsr_abs()
{
addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc) << 8;
push(d6502_pc >> 8);
push(d6502_pc);
d6502_pc = addr;
}
/************************************************************************************************/
static void op_and_inx()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++);
zpaddr += d6502_x;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_bit_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

value = hu6280_read(addr);
d6502_f &= 0x3d; /* clear negative, overflow and zero */
d6502_f |= value & 0xc0; /* set negative and overflow */
if((d6502_a & value) == 0)
	d6502_f |= FLAG_ZERO;
}

static void op_bit_imm()
{
value = hu6280_read(d6502_pc++);
d6502_f &= 0x3d; /* clear negative, overflow and zero */
d6502_f |= value & 0xc0; /* set negative and overflow */
if((d6502_a & value) == 0)
	d6502_f |= FLAG_ZERO;
}
/************************************************************************************************/
static void op_and_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_rol_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
if(value & 0x80)
	{
	value = value << 1;
	value |= d6502_f & 1; /* carry flag is bit0, hehe */
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value << 1;
	value |= d6502_f & 1;
	d6502_f &= FLAG_CARRY_MASK;
	}

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_plp_imp()
{
pop(d6502_f);
d6502_f |= FLAG_XXX;
}
/************************************************************************************************/
static void op_and_imm()
{
addr = d6502_pc++;

//opcycles++;
d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_rol_acc()
{
//opcycles++;
if(d6502_a & 0x80)
	{
	d6502_a = d6502_a << 1;
	d6502_a |= d6502_f & 1; /* carry flag is bit0, hehe */
	d6502_f |= FLAG_CARRY;
	}
else
	{
	d6502_a = d6502_a << 1;
	d6502_a |= d6502_f & 1;
	d6502_f &= FLAG_CARRY_MASK;
	}
checknz(d6502_a);
}
/************************************************************************************************/
static void op_bit_abs()
{
////opcycles++;
addr = hu6280_read(d6502_pc++);

////opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

////opcycles++;
value = hu6280_read(addr);
d6502_f &= 0x3d; /* clear negative, overflow and zero */
d6502_f |= value & 0xc0; /* set negative and overflow */
if((d6502_a & value) == 0)
	d6502_f |= FLAG_ZERO;
}
/************************************************************************************************/
static void op_and_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_rol_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
if(value & 0x80)
	{
	value = value << 1;
	value |= d6502_f & 1; /* carry flag is bit0, hehe */
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value << 1;
	value |= d6502_f & 1;
	d6502_f &= FLAG_CARRY_MASK;
	}

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_bmi_rel()
{
branch(d6502_f & FLAG_NEGATIVE);
}
/************************************************************************************************/
static void op_and_iny()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_and_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_rol_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
if(value & 0x80)
	{
	value = value << 1;
	value |= d6502_f & 1; /* carry flag is bit0, hehe */
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value << 1;
	value |= d6502_f & 1;
	d6502_f &= FLAG_CARRY_MASK;
	}
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_sec_imp()
{
//opcycles++;
d6502_f |= FLAG_CARRY;
}
/************************************************************************************************/
static void op_and_aby()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_and_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a &= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_rol_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
if(value & 0x80)
	{
	value = value << 1;
	value |= d6502_f & 1; /* carry flag is bit0, hehe */
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value << 1;
	value |= d6502_f & 1;
	d6502_f &= FLAG_CARRY_MASK;
	}
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_rti_imp()
{
pop(d6502_f);
pop(d6502_pc);
pop(value);
d6502_f |= FLAG_XXX;
d6502_pc |= value << 8;
}
/************************************************************************************************/
static void op_eor_inx()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_eor_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_lsr_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
d6502_f &= FLAG_CARRY_MASK;
d6502_f |= value & 1;
value = value >> 1;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_pha_imp()
{
push(d6502_a);
}
/************************************************************************************************/
static void op_eor_imm()
{
addr = d6502_pc++;

//opcycles++;
d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_lsr_acc()
{
//opcycles++;
d6502_f &= FLAG_CARRY_MASK;
d6502_f |= d6502_a & 1;
d6502_a = d6502_a >> 1;
checknz(d6502_a);
}
/************************************************************************************************/
static void op_jmp_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

d6502_pc = addr;
}
/************************************************************************************************/
static void op_eor_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_lsr_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
d6502_f &= FLAG_CARRY_MASK;
d6502_f |= value & 1;
value = value >> 1;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_bvc_rel()
{
branch((d6502_f & FLAG_OVERFLOW) == 0);
}
/************************************************************************************************/
static void op_eor_iny()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_eor_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_lsr_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
d6502_f |= value & 1;
value = value >> 1;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_cli_imp()
{
d6502_f &= FLAG_IRQDISABLE_MASK;
}
/************************************************************************************************/
static void op_eor_aby()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_eor_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a ^= hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_lsr_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
d6502_f |= value & 1;
value = value >> 1;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_rts_imp()
{
pop(d6502_pc);
pop(value);
d6502_pc |= value << 8;
d6502_pc++;
}
/************************************************************************************************/
static void op_adc_inx()
{
u16 zpaddr;
u16 newa;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_adc_zpg()
{
u16 newa;

addr = hu6280_read(d6502_pc++) | 0x2000;

value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ror_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

value = hu6280_read(addr);
if(value & 1)
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f &= FLAG_CARRY_MASK;
	}
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_pla_imp()
{
pop(d6502_a);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_adc_imm()
{
u16 newa;

addr = d6502_pc++;

value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ror_acc()
{
if(d6502_a & 1)
	{
	d6502_a = d6502_a >> 1;
	if(d6502_f & FLAG_CARRY)
		d6502_a |= 0x80;
	d6502_f |= FLAG_CARRY;
	}
else
	{
	d6502_a = d6502_a >> 1;
	if(d6502_f & FLAG_CARRY)
		d6502_a |= 0x80;
	d6502_f &= FLAG_CARRY_MASK;
	}
checknz(d6502_a);
}
/************************************************************************************************/
static void op_jmp_ind()
{
addr = hu6280_read16(hu6280_read16(d6502_pc++));
d6502_pc = addr;
}
/************************************************************************************************/
static void op_jmp_inx()
{
	u16 p00p;

	p00p = hu6280_read(d6502_pc++);
	p00p |= hu6280_read(d6502_pc++) << 8;
	p00p += d6502_x;

	addr = hu6280_read(p00p++);
	addr |= hu6280_read(p00p) << 8;

	d6502_pc = addr;
}
/************************************************************************************************/
static void op_adc_abs()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ror_abs()
{
addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
if(value & 1)
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f &= FLAG_CARRY_MASK;
	}
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_bvs_rel()
{
branch(d6502_f & FLAG_OVERFLOW);
}

static void op_bra_rel()
{
branch(1);
}
/************************************************************************************************/
static void op_adc_iny()
{
u16 zpaddr;
u16 newa;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_adc_zpx()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ror_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
if(value & 1)
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f &= FLAG_CARRY_MASK;
	}
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_sei_imp()
{
d6502_f |= FLAG_IRQDISABLE;
}
/************************************************************************************************/
static void op_adc_aby()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_adc_abx()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
value = hu6280_read(addr);
newa = d6502_a + value + (d6502_f & FLAG_CARRY); /* how convenient, carry flag is bit0  :) */
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(newa & 0xff00)
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ newa) & (value ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ror_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
if(value & 1)
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f |= FLAG_CARRY;
	}
else
	{
	value = value >> 1;
	if(d6502_f & FLAG_CARRY)
		value |= 0x80;
	d6502_f &= FLAG_CARRY_MASK;
	}
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_sta_inx()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_sty_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

hu6280_write(addr,d6502_y);
}
/************************************************************************************************/
static void op_sta_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_stx_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

hu6280_write(addr,d6502_x);
}
/************************************************************************************************/
static void op_dey_imp()
{
d6502_y--;
checknz(d6502_y);
}
/************************************************************************************************/
static void op_txa_imp()
{
d6502_a = d6502_x;
checknz(d6502_a);
}
/************************************************************************************************/
static void op_sty_abs()
{
addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

hu6280_write(addr,d6502_y);
}
/************************************************************************************************/
static void op_sta_abs()
{
addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_stx_abs()
{
addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

hu6280_write(addr,d6502_x);
}
/************************************************************************************************/
static void op_bcc_rel()
{
branch((d6502_f & FLAG_CARRY) == 0);
}
/************************************************************************************************/
static void op_sta_iny()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
addr += hu6280_read(zpaddr) << 8;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_sty_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

hu6280_write(addr,d6502_y);
}
/************************************************************************************************/
static void op_sta_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_stx_zpy()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
addr &= 0xff;
addr |= 0x2000;

hu6280_write(addr,d6502_x);
}
/************************************************************************************************/
static void op_tya_imp()
{
d6502_a = d6502_y;
checknz(d6502_a);
}
/************************************************************************************************/
static void op_sta_aby()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
addr += hu6280_read(d6502_pc++) << 8;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_txs_imp()
{
d6502_s = d6502_x;
}
/************************************************************************************************/
static void op_sta_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

hu6280_write(addr,d6502_a);
}
/************************************************************************************************/
static void op_ldy_imm()
{
addr = d6502_pc++;

d6502_y = hu6280_read(addr);
checknz(d6502_y);
}
/************************************************************************************************/
static void op_lda_ind()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
static void op_lda_inx()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ldx_imm()
{
addr = d6502_pc++;

d6502_x = hu6280_read(addr);
checknz(d6502_x);
}
/************************************************************************************************/
static void op_ldy_zpg()
{
addr = hu6280_read(d6502_pc++) | 0x2000;

d6502_y = hu6280_read(addr);
checknz(d6502_y);
}
/************************************************************************************************/
static void op_lda_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ldx_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
d6502_x = hu6280_read(addr);
checknz(d6502_x);
}
/************************************************************************************************/
static void op_tay_imp()
{
//opcycles++;
d6502_y = d6502_a;
checknz(d6502_y);
}
/************************************************************************************************/
static void op_lda_imm()
{
addr = d6502_pc++;

//opcycles++;
d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_tax_imp()
{
//opcycles++;
d6502_x = d6502_a;
checknz(d6502_x);
}
/************************************************************************************************/
static void op_ldy_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
d6502_y = hu6280_read(addr);
checknz(d6502_y);
}
/************************************************************************************************/
static void op_lda_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ldx_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
d6502_x = hu6280_read(addr);
checknz(d6502_x);
}
/************************************************************************************************/
static void op_bcs_rel()
{
branch(d6502_f & FLAG_CARRY);
}
/************************************************************************************************/
static void op_lda_iny()
{
u16 zpaddr;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ldy_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

d6502_y = hu6280_read(addr);
checknz(d6502_y);
}
/************************************************************************************************/
static void op_lda_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ldx_zpy()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
addr &= 0xff;
addr |= 0x2000;

d6502_x = hu6280_read(addr);
checknz(d6502_x);
}
/************************************************************************************************/
static void op_clv_imp()
{
//opcycles++;
d6502_f &= FLAG_OVERFLOW_MASK;
}
/************************************************************************************************/
static void op_lda_aby()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_tsx_imp()
{
//opcycles++;
d6502_x = d6502_s;
checknz(d6502_x);
}
/************************************************************************************************/
static void op_ldy_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_y = hu6280_read(addr);
checknz(d6502_y);
}
/************************************************************************************************/
static void op_lda_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_a = hu6280_read(addr);
checknz(d6502_a);
}
/************************************************************************************************/
static void op_ldx_aby()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
d6502_x = hu6280_read(addr);
checknz(d6502_x);
}
/************************************************************************************************/
static void op_cpy_imm()
{
u16 newvalue;

addr = d6502_pc++;

//opcycles++;
newvalue = (d6502_y + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_cmp_inx()
{
u16 zpaddr;
u16 newvalue;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_cpy_zpg()
{
u16 newvalue;

//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
newvalue = (d6502_y + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_cmp_zpg()
{
u16 newvalue;

//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_dec_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
value--;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_iny_imp()
{
//opcycles++;
d6502_y++;
checknz(d6502_y);
}
/************************************************************************************************/
static void op_cmp_imm()
{
u16 newvalue;

addr = d6502_pc++;

//opcycles++;
newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_dex_imp()
{
//opcycles++;
d6502_x--;
checknz(d6502_x);
}
/************************************************************************************************/
static void op_cpy_abs()
{
u16 newvalue;

//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
newvalue = (d6502_y + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_cmp_abs()
{
u16 newvalue;

//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_dec_abs()
{
//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
value--;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_bne_rel()
{
branch((d6502_f & FLAG_ZERO) == 0);
}
/************************************************************************************************/
static void op_cmp_iny()
{
u16 zpaddr;
u16 newvalue;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_cmp_zpx()
{
u16 newvalue;

addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_dec_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
value--;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_cld_imp()
{
//opcycles++;
d6502_f &= FLAG_DECIMAL_MASK;
}
/************************************************************************************************/
static void op_cmp_aby()
{
u16 newvalue;

addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_cmp_abx()
{
u16 newvalue;

addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
newvalue = (d6502_a + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_dec_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
value--;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_cpx_imm()
{
u16 newvalue;

addr = d6502_pc++;

newvalue = (d6502_x + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_sbc_inx()
{
u16 zpaddr;
u16 newa;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
zpaddr += d6502_x;
zpaddr &= 0x20FF;
addr = hu6280_read(zpaddr++);
addr |= hu6280_read(zpaddr) << 8;

value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_cpx_zpg()
{
u16 newvalue;

addr = hu6280_read(d6502_pc++) | 0x2000;

newvalue = (d6502_x + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_sbc_zpg()
{
u16 newa;

addr = hu6280_read(d6502_pc++) | 0x2000;

value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_inc_zpg()
{
//opcycles++;
addr = hu6280_read(d6502_pc++) | 0x2000;

//opcycles++;
value = hu6280_read(addr);

//opcycles++;
hu6280_write(addr,value);
value++;

//opcycles++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_inx_imp()
{
//opcycles++;
d6502_x++;
checknz(d6502_x);
}
/************************************************************************************************/
static void op_sbc_imm()
{
u16 newa;

addr = d6502_pc++;

value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_nop_imp()
{
}
/************************************************************************************************/
static void op_cpx_abs()
{
u16 newvalue;

//opcycles++;
addr = hu6280_read(d6502_pc++);

//opcycles++;
addr |= hu6280_read(d6502_pc++) << 8;

//opcycles++;
newvalue = (d6502_x + 0x100) - hu6280_read(addr);
d6502_f &= FLAG_CARRY_MASK;
if(newvalue & 0xff00)
	d6502_f |= FLAG_CARRY;
newvalue &= 0xff;
checknz(newvalue);
}
/************************************************************************************************/
static void op_sbc_abs()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_inc_abs()
{
addr = hu6280_read(d6502_pc++);
addr |= hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
value++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_beq_rel()
{
branch(d6502_f & FLAG_ZERO);
}
/************************************************************************************************/
static void op_sbc_iny()
{
u16 zpaddr;
u16 newa;

zpaddr = hu6280_read(d6502_pc++) | 0x2000;
addr = hu6280_read(zpaddr++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec++;
addr += hu6280_read(zpaddr) << 8;

value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_sbc_zpx()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_inc_zpx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr &= 0xff;
addr |= 0x2000;

value = hu6280_read(addr);
value++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/
static void op_sed_imp()
{
d6502_f |= FLAG_DECIMAL;
}
/************************************************************************************************/
static void op_sbc_aby()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr += d6502_y;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_sbc_abx()
{
u16 newa;

addr = hu6280_read(d6502_pc++);
addr += d6502_x;
if(addr & 0xff00)
	cyclesexec += EXTRA_CYCLE;
addr += hu6280_read(d6502_pc++) << 8;
value = hu6280_read(addr);
newa = d6502_a - value - (1 - (d6502_f & FLAG_CARRY));
d6502_f &= 0xbe; /* clear carry and overflow flags */
if(!(newa & 0xff00))
	d6502_f |= FLAG_CARRY;
d6502_f |= (((d6502_a ^ value) & (d6502_a ^ newa)) & 0x80) >> 1;
d6502_a = newa & 0xff;
#ifndef NES
if(d6502_f & FLAG_DECIMAL)
	{
	d6502_a -= 0x66;
	d6502_f &= FLAG_CARRY_MASK;
	if((d6502_a & 0x0f) > 0x09)
		d6502_a += 0x06;
	if((d6502_a & 0xf0) > 0x90)
		{
		d6502_a += 0x60;
		d6502_f |= FLAG_CARRY;
		}
	}
#endif
checknz(d6502_a);
}
/************************************************************************************************/
static void op_inc_abx()
{
addr = hu6280_read(d6502_pc++);
addr += d6502_x;
addr += hu6280_read(d6502_pc++) << 8;

value = hu6280_read(addr);
value++;
hu6280_write(addr,value);
checknz(value);
}
/************************************************************************************************/

static void op_csl_imp()
{
}

static void op_csh_imp()
{
}

static void op_tam_imm()
{
	u8 tmp = hu6280_read(d6502_pc++);
	if(tmp & 0x01) cpu->memorymap[0] = cpu->a;	
	if(tmp & 0x02) cpu->memorymap[1] = cpu->a;	
	if(tmp & 0x04) cpu->memorymap[2] = cpu->a;	
	if(tmp & 0x08) cpu->memorymap[3] = cpu->a;	
	if(tmp & 0x10) cpu->memorymap[4] = cpu->a;	
	if(tmp & 0x20) cpu->memorymap[5] = cpu->a;	
	if(tmp & 0x40) cpu->memorymap[6] = cpu->a;	
	if(tmp & 0x80) cpu->memorymap[7] = cpu->a;	
}

static void op_tma_imm()
{
	u8 tmp = hu6280_read(d6502_pc++);
	if(tmp & 0x01) cpu->a = cpu->memorymap[0];	
	if(tmp & 0x02) cpu->a = cpu->memorymap[1];	
	if(tmp & 0x04) cpu->a = cpu->memorymap[2];	
	if(tmp & 0x08) cpu->a = cpu->memorymap[3];	
	if(tmp & 0x10) cpu->a = cpu->memorymap[4];	
	if(tmp & 0x20) cpu->a = cpu->memorymap[5];	
	if(tmp & 0x40) cpu->a = cpu->memorymap[6];	
	if(tmp & 0x80) cpu->a = cpu->memorymap[7];		
}

static void op_stz_zpg()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	hu6280_write(addr,0);
}

static void op_stz_zpx()
{
	addr = (hu6280_read(d6502_pc++) + d6502_x) & 0xFF;
	addr |= 0x2000;
	hu6280_write(addr,0);
}

static void op_stz_abs()
{
	addr = hu6280_read16(d6502_pc);
	d6502_pc += 2;
	hu6280_write(addr,0);
}

static void op_stz_abx()
{
	addr = hu6280_read16(d6502_pc) + d6502_x;
	d6502_pc += 2;
	hu6280_write(addr,0);
}

static void op_cla_imp()
{
	cpu->a = 0;
}

static void op_clx_imp()
{
	cpu->x = 0;
}

static void op_cly_imp()
{
	cpu->y = 0;
}

static void op_tai()
{
	u16 src,dest,len,toggle;
	
	src = hu6280_read16(d6502_pc+0);
	dest = hu6280_read16(d6502_pc+2);
	len = hu6280_read16(d6502_pc+4);
	d6502_pc += 6;
	for(toggle=0;len-->0;toggle^=1,cpu->cycles+=6)
		hu6280_write(dest++,hu6280_read16(src+toggle));
}

static void op_tii()
{
	u16 src,dest,len;
	
	src = hu6280_read16(d6502_pc+0);
	dest = hu6280_read16(d6502_pc+2);
	len = hu6280_read16(d6502_pc+4);
	d6502_pc += 6;
	for(;len-->0;cpu->cycles+=6)
		hu6280_write(dest++,hu6280_read16(src++));
}

static op_inc_acc()
{
	cpu->a++;
	checknz(cpu->a);
}

static op_dec_acc()
{
	cpu->a--;
	checknz(cpu->a);
}

static void op_bsr_rel()
{
	push(d6502_pc >> 8);
	push(d6502_pc);
	value = hu6280_read(d6502_pc);
	d6502_pc++;
	addr = (s32)(u16)d6502_pc + (s8)value;
	d6502_pc = addr;
}

static void op_phx_imp()
{
	push(cpu->x);
}

static void op_phy_imp()
{
	push(cpu->y);
}

static void op_plx_imp()
{
	pop(cpu->x);
	checknz(cpu->x);
}

static void op_ply_imp()
{
	pop(cpu->y);
	checknz(cpu->y);
}

static void op_sxy_imp()
{
	data = d6502_x;
	d6502_x = d6502_y;
	d6502_y = data;
}

static void op_tst_izp()
{
	u8 tmp;

	value = hu6280_read(d6502_pc++);
	addr = hu6280_read(d6502_pc++) | 0x2000;
	tmp = hu6280_read(addr) & value;
	d6502_f &= ~0xC2;
	d6502_f |= tmp & 0x80;
	d6502_f |= tmp & 0x40;
	d6502_f |= (tmp == 0) ? 2 : 0;
}

static void op_tst_iab()
{
	u8 tmp;

	value = hu6280_read(d6502_pc++);
	addr = hu6280_read(d6502_pc++);
	addr |= hu6280_read(d6502_pc++) << 8;
	tmp = hu6280_read(addr) & value;
	d6502_f &= ~0xC2;
	d6502_f |= tmp & 0x80;
	d6502_f |= tmp & 0x40;
	d6502_f |= (tmp == 0) ? 2 : 0;
}

static void op_st_imm(int idx,u8 data)
{
	int physaddr = 0x1FE000 + idx;
	int physbank = physaddr >> 13;

	if(cpu->phys_write_page[physbank])
		cpu->phys_write_page[physbank][physaddr & 0x1FFF] = data;
	else if(cpu->phys_write_func[physbank])
		cpu->phys_write_func[physbank](physaddr,data);
	else
		log_message("hu6280: unhandled write at $%06X=$%02X\n",physaddr,data);
}

static void op_st0_imm()	{	op_st_imm(0,hu6280_read(d6502_pc++));	}
static void op_st1_imm()	{	op_st_imm(2,hu6280_read(d6502_pc++));	}
static void op_st2_imm()	{	op_st_imm(4,hu6280_read(d6502_pc++));	}

static void op_bbr0_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x01) == 0);
}

static void op_bbr1_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x02) == 0);
}

static void op_bbr2_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x04) == 0);
}

static void op_bbr3_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x08) == 0);
}

static void op_bbr4_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x10) == 0);
}

static void op_bbr5_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x20) == 0);
}

static void op_bbr6_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x40) == 0);
}

static void op_bbr7_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch((hu6280_read(addr) & 0x80) == 0);
}

static void op_bbs0_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x01);
}

static void op_bbs1_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x02);
}

static void op_bbs2_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x04);
}

static void op_bbs3_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x08);
}

static void op_bbs4_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x10);
}

static void op_bbs5_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x20);
}

static void op_bbs6_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x40);
}

static void op_bbs7_rel()
{
	addr = hu6280_read(d6502_pc++) | 0x2000;
	branch(hu6280_read(addr) & 0x80);
}

#define OP_SMB(name,bit) \
	static void name() { \
		addr = hu6280_read(d6502_pc++) | 0x2000; \
		hu6280_write(addr,hu6280_read(addr) | (1 << bit)); \
	}

#define OP_RMB(name,bit) \
	static void name() { \
		addr = hu6280_read(d6502_pc++) | 0x2000; \
		hu6280_write(addr,hu6280_read(addr) & ~(1 << bit)); \
	}

OP_SMB(op_smb0_zpg,0);
OP_SMB(op_smb1_zpg,1);
OP_SMB(op_smb2_zpg,2);
OP_SMB(op_smb3_zpg,3);
OP_SMB(op_smb4_zpg,4);
OP_SMB(op_smb5_zpg,5);
OP_SMB(op_smb6_zpg,6);
OP_SMB(op_smb7_zpg,7);

OP_RMB(op_rmb0_zpg,0);
OP_RMB(op_rmb1_zpg,1);
OP_RMB(op_rmb2_zpg,2);
OP_RMB(op_rmb3_zpg,3);
OP_RMB(op_rmb4_zpg,4);
OP_RMB(op_rmb5_zpg,5);
OP_RMB(op_rmb6_zpg,6);
OP_RMB(op_rmb7_zpg,7);

static voidcall fulloptable[256] =
	{
	op_brk_imp,op_ora_inx,op_sxy_imp,op_st0_imm,op_tsb_zpg,op_ora_zpg,op_asl_zpg,op_rmb0_zpg, /* 00-07 */
	op_php_imp,op_ora_imm,op_asl_acc,op_xxx_xxx,op_tsb_abs,op_ora_abs,op_asl_abs,op_bbr0_rel, /* 08-0f */
	op_bpl_rel,op_ora_iny,op_xxx_xxx,op_st1_imm,op_xxx_xxx,op_ora_zpx,op_asl_zpx,op_rmb1_zpg, /* 10-17 */
	op_clc_imp,op_ora_aby,op_inc_acc,op_xxx_xxx,op_xxx_xxx,op_ora_abx,op_asl_abx,op_bbr1_rel, /* 18-1f */
	op_jsr_abs,op_and_inx,op_xxx_xxx,op_st2_imm,op_bit_zpg,op_and_zpg,op_rol_zpg,op_rmb2_zpg, /* 20-27 */
	op_plp_imp,op_and_imm,op_rol_acc,op_xxx_xxx,op_bit_abs,op_and_abs,op_rol_abs,op_bbr2_rel, /* 28-2f */
	op_bmi_rel,op_and_iny,op_xxx_xxx,op_xxx_xxx,op_xxx_xxx,op_and_zpx,op_rol_zpx,op_rmb3_zpg, /* 30-37 */
	op_sec_imp,op_and_aby,op_dec_acc,op_xxx_xxx,op_xxx_xxx,op_and_abx,op_rol_abx,op_bbr3_rel, /* 38-3f */
	op_rti_imp,op_eor_inx,op_xxx_xxx,op_tma_imm,op_bsr_rel,op_eor_zpg,op_lsr_zpg,op_rmb4_zpg, /* 40-47 */
	op_pha_imp,op_eor_imm,op_lsr_acc,op_xxx_xxx,op_jmp_abs,op_eor_abs,op_lsr_abs,op_bbr4_rel, /* 48-4f */
	op_bvc_rel,op_eor_iny,op_xxx_xxx,op_tam_imm,op_csl_imp,op_eor_zpx,op_lsr_zpx,op_rmb5_zpg, /* 50-57 */
	op_cli_imp,op_eor_aby,op_phy_imp,op_xxx_xxx,op_xxx_xxx,op_eor_abx,op_lsr_abx,op_bbr5_rel, /* 58-5f */
	op_rts_imp,op_adc_inx,op_cla_imp,op_xxx_xxx,op_stz_zpg,op_adc_zpg,op_ror_zpg,op_rmb6_zpg, /* 60-67 */
	op_pla_imp,op_adc_imm,op_ror_acc,op_xxx_xxx,op_jmp_ind,op_adc_abs,op_ror_abs,op_bbr6_rel, /* 68-6f */
	op_bvs_rel,op_adc_iny,op_xxx_xxx,op_tii    ,op_stz_zpx,op_adc_zpx,op_ror_zpx,op_rmb7_zpg, /* 70-77 */
	op_sei_imp,op_adc_aby,op_ply_imp,op_xxx_xxx,op_jmp_inx,op_adc_abx,op_ror_abx,op_bbr7_rel, /* 78-7f */
	op_bra_rel,op_sta_inx,op_clx_imp,op_tst_izp,op_sty_zpg,op_sta_zpg,op_stx_zpg,op_smb0_zpg, /* 80-87 */
	op_dey_imp,op_bit_imm,op_txa_imp,op_xxx_xxx,op_sty_abs,op_sta_abs,op_stx_abs,op_bbs0_rel, /* 88-8f */
	op_bcc_rel,op_sta_iny,op_xxx_xxx,op_tst_iab,op_sty_zpx,op_sta_zpx,op_stx_zpy,op_smb1_zpg, /* 90-97 */
	op_tya_imp,op_sta_aby,op_txs_imp,op_xxx_xxx,op_stz_abs,op_sta_abx,op_stz_abx,op_bbs1_rel, /* 98-9f */
	op_ldy_imm,op_lda_inx,op_ldx_imm,op_xxx_xxx,op_ldy_zpg,op_lda_zpg,op_ldx_zpg,op_smb2_zpg, /* a0-a7 */
	op_tay_imp,op_lda_imm,op_tax_imp,op_xxx_xxx,op_ldy_abs,op_lda_abs,op_ldx_abs,op_bbs2_rel, /* a8-af */
	op_bcs_rel,op_lda_iny,op_lda_ind,op_xxx_xxx,op_ldy_zpx,op_lda_zpx,op_ldx_zpy,op_smb3_zpg, /* b0-b7 */
	op_clv_imp,op_lda_aby,op_tsx_imp,op_xxx_xxx,op_ldy_abx,op_lda_abx,op_ldx_aby,op_bbs3_rel, /* b8-bf */
	op_cpy_imm,op_cmp_inx,op_cly_imp,op_xxx_xxx,op_cpy_zpg,op_cmp_zpg,op_dec_zpg,op_smb4_zpg, /* c0-c7 */
	op_iny_imp,op_cmp_imm,op_dex_imp,op_xxx_xxx,op_cpy_abs,op_cmp_abs,op_dec_abs,op_bbs4_rel, /* c8-cf */
	op_bne_rel,op_cmp_iny,op_xxx_xxx,op_xxx_xxx,op_csh_imp,op_cmp_zpx,op_dec_zpx,op_smb5_zpg, /* d0-d7 */
	op_cld_imp,op_cmp_aby,op_phx_imp,op_xxx_xxx,op_xxx_xxx,op_cmp_abx,op_dec_abx,op_bbs5_rel, /* d8-df */
	op_cpx_imm,op_sbc_inx,op_xxx_xxx,op_xxx_xxx,op_cpx_zpg,op_sbc_zpg,op_inc_zpg,op_smb6_zpg, /* e0-e7 */
	op_inx_imp,op_sbc_imm,op_nop_imp,op_xxx_xxx,op_cpx_abs,op_sbc_abs,op_inc_abs,op_bbs6_rel, /* e8-ef */
	op_beq_rel,op_sbc_iny,op_xxx_xxx,op_tai    ,op_xxx_xxx,op_sbc_zpx,op_inc_zpx,op_smb7_zpg, /* f0-f7 */
	op_sed_imp,op_sbc_aby,op_plx_imp,op_xxx_xxx,op_xxx_xxx,op_sbc_abx,op_inc_abx,op_bbs7_rel  /* f8-ff */
	};
